//
//  SKYWebViewController.m
//  SkyonSDK_Example
//
//  Created by 张二帅 on 2018/6/11.
//  Copyright © 2018年 Skyon. All rights reserved.
//

#import "SKYWebViewController.h"

@interface SKYWebViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation SKYWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //    self.webView.delegate = self;
    NSString *urlString = @"http://www.itaiping.com/pc/index/";
    urlString = @"http://smarket.tp95589.com/neiqin-score-mobile/scoreService.html";
    urlString = @"https://m.touker.com/account/stock/agent/index.htm";
    [self.webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]]];
    self.webView.delegate = self;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"%@",self.webView.delegate);
}



+ (NSString *)cookieCheck_id {
    return [self cookieWithCookieName:@"check_id"];
}

+ (NSString *)cookieLgn_ur {
    return [self cookieWithCookieName:@"lgn_ur"];
}

+ (NSString *)cookieWithCookieName:(NSString *)cookieName {
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    __block NSString *cookieValue = @"";
    [storage.cookies enumerateObjectsUsingBlock:^(NSHTTPCookie * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj.properties[NSHTTPCookieName] isEqualToString:cookieName]) {
            cookieValue = obj.properties[NSHTTPCookieValue];
        }
    }];
    return cookieValue;
}

#pragma mark - UIWebViewDelegate
- (void)webViewDidStartLoad:(UIWebView *)webView;{
    
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error;{
    NSLog(@"%@",error.localizedDescription);
}

@end
